package com.vero.management.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vero.management.service.IVaccineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vero.common.log.annotation.Log;
import com.vero.common.log.enums.BusinessType;
import com.vero.common.security.annotation.RequiresPermissions;
import com.vero.system.api.domain.Vaccine;
import com.vero.common.core.web.controller.BaseController;
import com.vero.common.core.web.domain.AjaxResult;
import com.vero.common.core.utils.poi.ExcelUtil;
import com.vero.common.core.web.page.TableDataInfo;

/**
 * 疫苗信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/vaccine")
public class VaccineController extends BaseController
{
    @Autowired
    private IVaccineService vaccineService;

    /**
     * 查询疫苗信息列表
     */
   // @RequiresPermissions("vaccine:vaccine:list")
    @GetMapping("/list")
    public TableDataInfo list(Vaccine vaccine)
    {
        startPage();
        List<Vaccine> list = vaccineService.selectVaccineList(vaccine);
        return getDataTable(list);
    }

    /**
     * 导出疫苗信息列表
     */
    @RequiresPermissions("vaccine:vaccine:export")
    @Log(title = "疫苗信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vaccine vaccine)
    {
        List<Vaccine> list = vaccineService.selectVaccineList(vaccine);
        ExcelUtil<Vaccine> util = new ExcelUtil<Vaccine>(Vaccine.class);
        util.exportExcel(response, list, "疫苗信息数据");
    }

    /**
     * 获取疫苗信息详细信息
     */
    @RequiresPermissions("vaccine:vaccine:query")
    @GetMapping(value = "/{vaccineId}")
    public AjaxResult getInfo(@PathVariable("vaccineId") Long vaccineId)
    {
        return success(vaccineService.selectVaccineByVaccineId(vaccineId));
    }

    /**
     * 新增疫苗信息
     */
    @RequiresPermissions("vaccine:vaccine:add")
    @Log(title = "疫苗信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Vaccine vaccine)
    {
        return toAjax(vaccineService.insertVaccine(vaccine));
    }

    /**
     * 修改疫苗信息
     */
    @RequiresPermissions("vaccine:vaccine:edit")
    @Log(title = "疫苗信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Vaccine vaccine)
    {
        return toAjax(vaccineService.updateVaccine(vaccine));
    }

    /**
     * 删除疫苗信息
     */
    @RequiresPermissions("vaccine:vaccine:remove")
    @Log(title = "疫苗信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vaccineIds}")
    public AjaxResult remove(@PathVariable Long[] vaccineIds)
    {
        return toAjax(vaccineService.deleteVaccineByVaccineIds(vaccineIds));
    }
}
